package com.lq.ecoldchain.ui.goodstype.goodsitem

import android.os.Bundle
import android.support.v7.app.AppCompatActivity
import com.alibaba.android.arouter.facade.annotation.Route
import com.lq.ecoldchain.R
import com.lq.ecoldchain.base.BaseNavigator
import com.lq.ecoldchain.entity.EventAll
import com.lq.ecoldchain.entity.GoodsType
import com.lq.ecoldchain.entity.GoodsTypeBean
import com.lq.ecoldchain.ui.goodstype.GoodsItemRecyclerAdapter
import kotlinx.android.synthetic.main.activity_goods_item.*
import org.greenrobot.eventbus.EventBus

/*
*2019/1/10 0010  15:03
*function by lq
*/
@Route(path = BaseNavigator.goodItem)
class GoodsItemActivity : AppCompatActivity() {
    val list by lazy { ArrayList<GoodsType>() }
    val adapter by lazy { GoodsItemRecyclerAdapter(list) }
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_goods_item)
        goodsItemContentRv.adapter = adapter

        val data = intent.getParcelableExtra<GoodsTypeBean>("data")
        list.clear()
        list.addAll(data.goodsTypes)
        adapter.setOnItemChildClickListener { _, _, position ->
            EventBus.getDefault().postSticky(EventAll.GoodsTypeItem(list[position]))
            finish()
        }
    }

}